package cn.shopifymall.camunda717.listener;

import cn.shopifymall.camunda717.service.WorkflowService;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.spring.boot.starter.event.PostDeployEvent;
import org.camunda.bpm.spring.boot.starter.event.TaskEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
class GlobalTaskListener {

    @Autowired
    private WorkflowService workflowService;

    @EventListener
    public void onTaskEvent(DelegateTask taskDelegate) {
        // handle mutable task event，可以做修改
        if ("create".equals(taskDelegate.getEventName())) {
            workflowService.syncDataWhenTaskCreate(taskDelegate);
        }
    }

    @EventListener
    public void onTaskEvent(TaskEvent taskEvent) {
        // handle immutable task event，不可做修改
        if ("create".equals(taskEvent.getEventName())) {

        }
    }

    @EventListener
    public void postDeploy(PostDeployEvent event) {

    }

}
